/**
 * 
 */
package autoUpdater.helper;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
import java.util.Scanner;

import javax.swing.JOptionPane;

import autoUpdater.AutoUpdaterMain;



/**
 * @author Christian
 *
 */
public class JarStarter {
	
	/**
	 * 
	 */
	public void startHelden(File heldenJar) {

		//loadConfig();

			StringBuilder command = new StringBuilder();
			if (AutoUpdaterMain.isDebugMode()) {
				System.out.println("Helden wird gestartet");
			}
			command.append("java");
			command.append(" ");
			
			command.append("-jar");
			command.append(" ");
			command.append(heldenJar.getName());
			command.append(" ");
			
			if (AutoUpdaterMain.isDebugMode()) {
				System.out.println(command.toString());
			}
			
			// Helden starten
			try {
				@SuppressWarnings("unused")
				Process proc = Runtime.getRuntime().exec(command.toString(), null, heldenJar.getParentFile());
				
				// if (UpdaterConfig.isDebugMode()) {
				 Scanner scanner = new Scanner(proc.getErrorStream());
				 while (scanner.hasNext()) {
				 System.out.println(scanner.next());
				 }
//				 scanner.close();
				// }
			} catch (IOException e) {
				e.printStackTrace();
			}
			System.exit(0);
		
	}
}
